﻿using DadayunApi.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KbtSync.Model
{
    /// <summary>
    /// CRM系统库存报表
    /// </summary>
    public class StorageReport
    {
        public List<StorageResult> Results { get; set; }
    }

    public  class StorageResult
    {

        [JsonProperty(PropertyName = "F1")]//指定搭搭云报表中的字段名称。下同
        public string ErpItemCode { get; set; }

        [JsonProperty(PropertyName = "F3")]
        public string ProdSerie { get; set; }

        [JsonProperty(PropertyName = "F4")]
        public string ProdCatalog { get; set; }
               
        [JsonProperty(PropertyName = "F5")]
        public string ModelNo { get; set; }

        [JsonProperty(PropertyName = "F7")]
        public string ProdName { get; set; }

        [JsonProperty(PropertyName = "F8")]
        public string Spec { get; set; }

             
        [JsonProperty(PropertyName = "F9")]
        public string Unit { get; set; }

        public string Note { get; set; }

        [JsonProperty(PropertyName = "F10")]
        public double Version { get; set; }

        [JsonProperty(PropertyName = "F14")]
        public DateTime? OnStoreTime { get; set; }

        [JsonProperty(PropertyName = "F15")]
        public double UsableQty { get; set; }

        [JsonProperty(PropertyName = "F16", NullValueHandling = NullValueHandling.Ignore)]
        public string WareHouse { get; set; }

        [JsonProperty(PropertyName = "F17", NullValueHandling = NullValueHandling.Ignore)]
        public double StockQty { get; set; }

        [JsonProperty(PropertyName = "F18", NullValueHandling = NullValueHandling.Ignore)]
        public double LockQty { get; set; }

        public ReportDataObject DataObjs { get; set; }

        public StorageResult() { }
        public StorageResult(ProductReportResult p)
        {
            ErpItemCode = p.ErpItemCode;
            ProdName = p.ProdName;
            ModelNo = p.ModelNo;
            Version = p.Version;
            Spec = p.Spec;
            Unit = p.Unit;

            OnStoreTime = p.OnStoreTime;
        }
        public StorageResult(ProductReportResult p, ErpStorageInfo s)
        {
            ErpItemCode = p.ErpItemCode;
            ProdName = p.ProdName;
            WareHouse = s.WareHouse;
            StockQty = s.StockQty;
            LockQty = 0;
            UsableQty = StockQty - LockQty;            
            ModelNo = p.ModelNo;
            Version = p.Version;
            Spec = p.Spec;
            Unit = p.Unit;           
            OnStoreTime = p.OnStoreTime;
            
        }
    }

    
}
